package com.gyh.stlserver.controller;

import com.aliyuncs.exceptions.ClientException;
import com.gyh.stlserver.constants.Constants;
import com.gyh.stlserver.util.OssUtil;
import com.gyh.stlserver.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private OssUtil ossUtil;
    /*上传图片*/
    @PostMapping("/savePic")
    public Result savePic(@RequestBody MultipartFile imgFile) throws ClientException {
        String path = ossUtil.upload(imgFile);
        return Result.success(Constants.STATUS_200,null,path);
    }
}
